package biz;


import java.util.HashMap;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import bean.UserObject;
import dto.UserDto;


/**
 * 登录business logic
 */
public class LoginBizImpl extends SqlMapClientDaoSupport implements LoginBiz
{
    /**
     * 取得登录用户信息
     * 
     * @param userId 用户ID
     * @param password 用户密码
     * @return UserObject 用户信息
     */
    public UserObject selectUserObject( String userId, String password )
    {
        // 用户信息
        UserObject uo = new UserObject();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put( "userId", userId );
        map.put( "password", password );
        try
        {
            UserDto userDto = (UserDto)getSqlMapClientTemplate().queryForObject( "user.select", map );
            if ( userDto == null )
            {
                return null;
            }
            BeanUtils.copyProperties( uo, userDto );
        }
        catch ( Exception e )
        {
            throw new BizLogicException( e );
        }

        return uo;
    }

}
